﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;
using NHibernate;
using FluentNHibernate.Data;

namespace BankCreditPortfolio.DAL.Entities
{
    public class OrderHistoryPersistence
    {
        public virtual int OrderHistoryId { get; set; }

        public virtual string CommentsOperationsAnalyst { get; set; }
        public virtual DateTime? DateOperationsAnalyst { get; set; }
        public virtual Banker OperationsAnalyst { get; set; }

        public virtual string CommentsSafetyOfficer { get; set; }
        public virtual DateTime? DateSafetyOfficer { get; set; }
        public virtual Banker SafetyOfficer { get; set; }

        public virtual string CommentsCustomerEngineer { get; set; }
        public virtual DateTime? DateCustomerEngineer { get; set; }
        public virtual Banker CustomerEngineer { get; set; }

        public virtual string CommentsCreditCommittieMember { get; set; }
        public virtual DateTime? DateCreditCommittieMember { get; set; }
        public virtual Banker CreditCommittieMember { get; set; }

        public virtual OrderInfoPersistence OrderInfo { get; set; }
    }

    public class OrderHistory : OrderHistoryPersistence
    {
        new public OrderInfo OrderInfo { get; set; }
    }

    public class OrderHistoryMap : ClassMap<OrderHistoryPersistence>
    {
        public OrderHistoryMap()
        {
            Id(x => x.OrderHistoryId).GeneratedBy.HiLo("orderhistory");
            Id(x => x.OrderHistoryId).Unique();

            Map(x => x.CommentsOperationsAnalyst);
            Map(x => x.DateOperationsAnalyst);
            References(x => x.OperationsAnalyst).Column("IdOperationsAnalyst");

            Map(x => x.CommentsSafetyOfficer);
            Map(x => x.DateSafetyOfficer);
            References(x => x.SafetyOfficer).Column("IdSafetyOfficer");

            Map(x => x.CommentsCustomerEngineer);
            Map(x => x.DateCustomerEngineer);
            References(x => x.CustomerEngineer).Column("IdCustomerEngineer");

            Map(x => x.CommentsCreditCommittieMember);
            Map(x => x.DateCreditCommittieMember);
            References(x => x.CreditCommittieMember).Column("IdCreditCommittieMember");

            References(x => x.OrderInfo).Column("OrderInfoId");
            Table("OrderHistory");
        }
    }
}
